不将字符串识别为对象 [英] Not Recognising String as Object

查看:109
本文介绍了不将字符串识别为对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


Hi,


我有一个宏导入文本文件并执行多个格式/内容更改,其中一些响应输入框和用户表单。最后一个功能旨在提供建议的文件名以将完成的文档另存为。导入的数据
包含一个单元,其中粘贴了导入文件名,目录路径和扩展名。例如:

I have a macro that imports a text file and performs multiple format/content changes, some in response to input boxes and user forms. The final feature is intended to provide a suggested filename to save the completed document as. The data that is imported contains a cell in which the import filename, directory path and extension are pasted. For example:


C:\ Users \whay \Documents \Will's Files \ Methane Diesel Benchmarking\Millbrook测试\官方周期数据\MD_Benchmarking-097.txt

C:\Users\whay\Documents\Will's Files\Methane Diesel Benchmarking\Millbrook Testing\Official Cycle Data\MD_Benchmarking-097.txt


我希望建议的新文件名包含导入文件名(没有扩展名或文件路径)另外4个字符。在这个例子中:

I want the suggested new filename to consist of the import filename (without extension or file path) with an additional 4 characters. In this instance:


MD_Benchmarking-097_REC(我使用'另存为'功能保存为文本文件,以便新的扩展稍后处理)

MD_Benchmarking-097_REC (I'm using the 'save as' function to save as a text file so the new extension is handled later)


到目前为止我所采用的路线是:

The route I have taken so far is:


1)选择单元格并定义字符串作为其内容,2)确定字符串中的字符数,3)从字符串长度减去23以确定要从中删除的字符数开始,4)删除字符。

1) Select cell and define a string as it's contents, 2) Determine number of characters in the string, 3) Subtract 23 from string length to determine number of characters to remove from start, 4) Remove characters.


我一直在尝试使用'.Remove'函数,但似乎我不能将它与字符串结合使用,因为它不被识别为对象。我所做的一切尝试失败,我一直在拖网论坛和帮助主题多年。

I've been trying to use the '.Remove' function but it seems I can't use this in conjunction with a string as it is not recognised as an object. Everything I try fails and I've been trawling the forums and help topics for ages.



有人可以帮忙吗?

Can anyone help?


干杯。

推荐答案

您好,

我想你应该看看:https://msdn.microsoft.com/en-us/library/dd789093.aspx?f = 255& MSPPError = -2147217396

I think you should have a look at: https://msdn.microsoft.com/en-us/library/dd789093.aspx?f=255&MSPPError=-2147217396

例如:

dim myString as string

dim myString as string

myString  = range(" a1")。value

myString  = range("a1").value

msgbox(len(myString)) '字符串长度

msgbox(len(myString ) )   'string length

msgbox(mid(mystring,23)) '获取位置23的所有字符

msgbox( mid(mystring,23) )  'get all characters from position 23

希望有所帮助


这篇关于不将字符串识别为对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆